//接口
interface IPerson {
    readonly ID: number; //readonly只读属性加在前面，应用在属性上面
    age?: number;//?代表可选属性
    name: string;
}

let viking: IPerson = {
    ID: 1,
    age: 20,
    name: 'li'
}
viking.ID=12 //报错Cannot assign to 'ID' because it is a read-only property

interface radio {
    openradio(): void;
    closeradio(): void;
}
interface battery extends radio { //接口可以继承
    checkoutradio(): void;
}

class car implements radio {
    openradio() {
        console.log('open car radio')
    }
    closeradio() {
        console.log('close car radio')
    }
}

class phone implements radio {
    openradio() {
        console.log('open phone radio')
    }
    closeradio() {
        console.log('close phone radio')
    }
}

let carone: radio = new car();
carone.openradio()
carone.closeradio()

let phoneone: radio = new phone();
phoneone.openradio()
phoneone.closeradio()

function doall(r: radio) {
    r.closeradio()
    r.openradio()
}
let cartwo = new car();
let phonetwo = new phone();
doall(cartwo)
doall(phonetwo)



